package com.yuexun.beilunpatient.ui.recipe.adapter;

import android.os.Bundle;
import android.view.View;
import android.widget.AbsListView;
import android.widget.ListView;
import android.widget.TextView;

import com.yuexun.beilunpatient.R;
import com.yuexun.beilunpatient.baselistener.ICallBackListener;

import org.kymjs.kjframe.widget.AdapterHolder;
import org.kymjs.kjframe.widget.KJAdapter;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
 * Created by chenss on 2018/5/8 0008.
 */

public class RecipeListAdapter extends KJAdapter<String> {

    ICallBackListener backListener;

    public void setBackListener(ICallBackListener backListener) {
        this.backListener = backListener;
    }

    public RecipeListAdapter(AbsListView view, Collection<String> mDatas, int itemLayoutId) {
        super(view, mDatas, itemLayoutId);
    }

    @Override
    public void convert(AdapterHolder helper, String item, boolean isScrolling, final int position) {
        super.convert(helper, item, isScrolling, position);

        ListView recipe_list = helper.getView(R.id.recipe_list);

        List<String> strings = new ArrayList<>();
        strings.add("");
        strings.add("");
//        DispensingListListAdapter adapter = new DispensingListListAdapter(recipe_list, strings, R.layout.item_dispensinglist_list);
//        recipe_list.setAdapter(adapter);

        TextView textView = helper.getView(R.id.use_drug);
        textView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Bundle bundle = new Bundle();
                bundle.putInt("position", position);
                bundle.putInt("type", 1);
                backListener.callback(bundle);
            }
        });

        TextView tv_detail = helper.getView(R.id.tv_detail);
        tv_detail.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Bundle bundle = new Bundle();
                bundle.putInt("position", position);
                bundle.putInt("type", 2);
                backListener.callback(bundle);
            }
        });
    }

}
